<template>
	<view class="container">
		<!-- 小程序头部兼容 -->
		<!-- #ifdef MP -->
		<view class="mp-search-box">
			<input class="ser-input" type="text" placeholder="输入关键字搜索" @click="navToSearchPage()" disabled />
		</view>
		<!-- #endif -->

		<!-- 头部轮播 -->
		<view class="carousel-section">
			<!-- 标题栏和状态栏占位符 -->
			<view class="titleNview-placing"></view>
			<!-- 背景色区域 -->
			<view class="titleNview-background" :style="{backgroundColor:titleNViewBackground}"></view>
			<swiper class="carousel" duration="500" interval="5000" autoplay="true" circular @change="swiperChange">
				<swiper-item v-for="(item, index) in carouselList" :key="index"
					class="carousel-item"><!-- @click="navToDetailPage({title: '轮播广告'})" -->
					<image :src="item.url" />
				</swiper-item>
			</swiper>
			<!-- 自定义swiper指示器 -->
			<view class="swiper-dots">
				<text class="num">{{swiperCurrent+1}}</text>
				<text class="sign">/</text>
				<text class="num">{{swiperLength}}</text>
			</view>
		</view>

		<view class="announcement-section">
			<view class="announcement-container">
				<view class="announcement-title">信息公告</view>
				<swiper class="announcement-swiper" duration="500" interval="5000" autoplay="true" vertical="true"
					circular>
					<block>
						<swiper-item v-for="(item, index) in articleList" :key="index" @click="navToArticlePage(item)">
							<view class="announcement-content">{{item.title}}</view>
						</swiper-item>
					</block>
				</swiper>
			</view>
		</view>

		<!-- 分类 -->
		<view class="cate-section">
			<view class="cate-item" v-for="(item, index) in categoryList" :key="index" @click="CategoryErJi(item.id)">
				<image :src="item.iconUrl"></image>
				<text>{{item.name}}</text>
			</view>
		</view>

		<!-- <view class="ad-1">
			<image src="/static/temp/ad1.jpg" mode="scaleToFill"></image>
		</view> -->

		<!-- 秒杀楼层 -->
		<view class="seckill-section m-t">
			<view class="s-header">
				<image class="s-img" src="/static/temp/secskill-img.jpg" mode="widthFix"></image>
				<text class="tip">{{ currentSessionText }}</text>
				<text class="hour timer">{{ hours }}</text>
				<text class="minute timer">{{ minutes }}</text>
				<text class="second timer">{{ seconds }}</text>
				<text class="yticon icon-you" @click="navToSeckillDetailPage()"></text>
			</view>
			<scroll-view class="floor-list" scroll-x>
				<view class="scoll-wrapper">
					<view v-for="(item, index) in seckillBatchList" :key="index" class="floor-item"
						@click="navToDetailPage1(item)">
						<image :src="item.dtsGoods.picUrl" mode="aspectFill"></image>
						<text class="title clamp">{{item.dtsGoods.name}}</text>
						<text class="price">￥{{item.dtsGoods.retailPrice}}</text>
					</view>
				</view>
			</scroll-view>
		</view>

		<!-- 团购楼层 -->
		<!-- <view class="f-header m-t">
			<image src="/static/temp/h1.png"></image>
			<view class="tit-box">
				<text class="tit">精品团购</text>
				<text class="tit2">Boutique Group Buying</text>
			</view>
			<text class="yticon icon-you"></text>
		</view>
		 -->
		<!-- <view class="group-section">
			<swiper class="g-swiper" :duration="500">
				<swiper-item class="g-swiper-item" v-for="(item, index) in goodsList" :key="index" v-if="index%2 === 0"
					@click="navToDetailPage(item)">
					<view class="g-item left">
						<image :src="item.image" mode="aspectFill"></image>
						<view class="t-box">
							<text class="title clamp">{{item.title}}</text>
							<view class="price-box">
								<text class="price">￥{{item.price}}</text>
								<text class="m-price">￥188</text>
							</view>

							<view class="pro-box">
								<view class="progress-box">
									<progress percent="72" activeColor="#fa436a" active stroke-width="6" />
								</view>
								<text>6人成团</text>
							</view>
						</view>

					</view>
					<view class="g-item right">
						<image :src="goodsList[index+1].image" mode="aspectFill"></image>
						<view class="t-box">
							<text class="title clamp">{{goodsList[index+1].title}}</text>
							<view class="price-box">
								<text class="price">￥{{goodsList[index+1].price}}</text>
								<text class="m-price">￥188</text>
							</view>
							<view class="pro-box">
								<view class="progress-box">
									<progress percent="72" activeColor="#fa436a" active stroke-width="6" />
								</view>
								<text>10人成团</text>
							</view>
						</view>
					</view>
				</swiper-item>

			</swiper>
		</view> -->



		<!-- 全网首发 -->
		<view class="f-header m-t">
			<!-- <image src="/static/temp/h1.png"></image> -->
			<view class="tit-box">
				<text class="tit">全网 · 新品首发</text>
				<text class="tit2">全网最新上架</text>
			</view>
			<text class="yticon icon-you" @click="toNewGoodsDetail()"></text>
		</view>

		<view class="guess-section">
			<view v-for="(item, index) in newGoodsList.slice(0, 10)" :key="index" class="guess-item"
				@click="navToDetailPage(item)">
				<view class="image-wrapper">
					<image :src="item.picUrl" mode="aspectFill"></image>
				</view>
				<text class="title clamp">{{item.brief}}</text>
				<text class="price">￥{{item.retailPrice}}</text>
			</view>
		</view>

		<!-- 人气推荐 -->
		<view class="f-header m-t">
			<!-- <image src="/static/temp/h1.png"></image> -->
			<view class="tit-box">
				<text class="tit">人气推荐</text>
				<text class="tit2">根据销量、搜索、好评等综合的出</text>
			</view>
			<text class="yticon icon-you" @click="toHotGoodsDetail"></text>

		</view>

		<view class="guess-section">
			<view v-for="(item, index) in hotGoodsList.slice(0, 10)" :key="index" class="guess-item"
				@click="navToDetailPage(item)">
				<view class="image-wrapper">
					<image :src="item.picUrl" mode="aspectFill"></image>
				</view>
				<text class="title clamp">{{item.brief}}</text>
				<text class="price">￥{{item.retailPrice}}</text>
			</view>
		</view>



		<!-- 分类推荐楼层 -->
		<!-- <view class="f-header m-t">
			<image src="/static/temp/h1.png"></image>
			<view class="tit-box">
				<text class="tit">分类精选</text>
				<text class="tit2">Competitive Products For You</text>
			</view>
			<text class="yticon icon-you"></text>
		</view>
		<view class="hot-floor">
			<view class="floor-img-box">
				<image class="floor-img" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1553409398864&di=4a12763adccf229133fb85193b7cc08f&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201703%2F19%2F20170319150032_MNwmn.jpeg" mode="scaleToFill"></image>
			</view>
			<scroll-view class="floor-list" scroll-x>
				<view class="scoll-wrapper">
					<view 
						v-for="(item, index) in goodsList" :key="index"
						class="floor-item"
						@click="navToDetailPage(item)"
					>
						<image :src="item.image" mode="aspectFill"></image>
						<text class="title clamp">{{item.title}}</text>
						<text class="price">￥{{item.price}}</text>
					</view>
					<view class="more">
						<text>查看全部</text>
						<text>More+</text>
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="hot-floor">
			<view class="floor-img-box">
				<image class="floor-img" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1553409984228&di=dee176242038c2d545b7690b303d65ea&imgtype=0&src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F5ef4da9f17faaf4612f0d5046f4161e556e9bbcfdb5b-rHjf00_fw658" mode="scaleToFill"></image>
			</view>
			<scroll-view class="floor-list" scroll-x>
				<view class="scoll-wrapper">
					<view 
						v-for="(item, index) in goodsList" :key="index"
						class="floor-item"
						@click="navToDetailPage(item)"
					>
						<image :src="item.image3" mode="aspectFill"></image>
						<text class="title clamp">{{item.title}}</text>
						<text class="price">￥{{item.price}}</text>
					</view>
					<view class="more">
						<text>查看全部</text>
						<text>More+</text>
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="hot-floor">
			<view class="floor-img-box">
				<image class="floor-img" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1553409794730&di=12b840ec4f5748ef06880b85ff63e34e&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F01dc03589ed568a8012060c82ac03c.jpg%40900w_1l_2o_100sh.jpg" mode="scaleToFill"></image>
			</view>
			<scroll-view class="floor-list" scroll-x>
				<view class="scoll-wrapper">
					<view 
						v-for="(item, index) in goodsList" :key="index"
						class="floor-item"
						@click="navToDetailPage(item)"
					>
						<image :src="item.image2" mode="aspectFill"></image>
						<text class="title clamp">{{item.title}}</text>
						<text class="price">￥{{item.price}}</text>
					</view>
					<view class="more">
						<text>查看全部</text>
						<text>More+</text>
					</view>
				</view>
			</scroll-view>
		</view> -->

		<!-- 分类商品 -->
		<view v-for="(category, catIndex) in categoryGoods" :key="catIndex" v-if="category.goodsList.length > 0"
			@click="CategoryErJi(category.id)">
			<view class="f-header m-t">
				<view class="tit-box">
					<text class="tit">{{category.name}}</text>
				</view>
				<text class="yticon icon-you"></text>
			</view>

			<view class="guess-section">
				<view v-for="(item, index) in category.goodsList" :key="index" class="guess-item"
					@click="navToDetailPage(item)">
					<view class="image-wrapper">
						<image :src="item.picUrl" mode="aspectFill"></image>
					</view>
					<text class="title clamp">{{item.brief}}</text>
					<text class="price">￥{{item.retailPrice}}</text>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		getAd
	} from '@/config/api/ad.js';
	import {
		getNewGoods,
		getHotGoods,
		getCategoryGoods
	} from '@/config/api/goods.js';
	import {
		getArticle
	} from '@/config/api/article.js';
	import {
		getOrder
	} from '@/config/api/category.js';
	import {
		getSeckillBathList,
		getSeckillBatch
	} from '@/config/api/seckillBatch.js';
	export default {

		data() {
			return {
				titleNViewBackground: '',
				swiperCurrent: 0,
				swiperLength: 0,
				carouselList: [], // 广告
				goodsList: [],
				seckillBatchList: [], // 秒杀
				newGoodsList: [], // 新品首发
				hotGoodsList: [], // 人气推荐
				articleList: [], // 公告
				categoryGoods: [], // 分类商品
				categoryList: [], //一级目录
				sessions: [{
						startTime: '08:00',
						endTime: '10:00',
						text: '8点场'
					},
					{
						startTime: '10:00',
						endTime: '14:00',
						text: '10点场'
					},
					{
						startTime: '14:00',
						endTime: '16:00',
						text: '14点场'
					},
					{
						startTime: '16:00',
						endTime: '20:00',
						text: '16点场'
					},
					{
						startTime: '20:00',
						endTime: '22:00',
						text: '20点场'
					}
				],
				hours: '00',
				minutes: '00',
				seconds: '00',
				currentSessionText: '等待中',
				timer: null,
				currentSeckillBatch: null,
			};
		},

		onLoad() {
			this.loadData();
		},
		mounted() {
			this.updateCountdown()
			this.timer = setInterval(() => {
				this.updateCountdown()
			}, 1000)
		},
		beforeDestroy() {
			clearInterval(this.timer)
		},
		methods: {
			updateCountdown() {
				const now = new Date()
				const currentHour = now.getHours()
				const currentMinute = now.getMinutes()
				const currentSecond = now.getSeconds()

				// 计算当前时间戳（秒）
				const currentTime = currentHour * 3600 + currentMinute * 60 + currentSecond

				// 查找当前应该显示的场次
				let currentSession = null
				let nextSession = null

				for (let i = 0; i < this.sessions.length; i++) {
					const session = this.sessions[i]
					const [startHour, startMinute] = session.startTime.split(':').map(Number)
					const [endHour, endMinute] = session.endTime.split(':').map(Number)

					// 计算场次开始和结束的时间戳（秒）
					const sessionStart = startHour * 3600 + startMinute * 60
					const sessionEnd = endHour * 3600 + endMinute * 60

					// 判断当前时间是否在该场次内
					if (currentTime >= sessionStart && currentTime < sessionEnd) {
						currentSession = session
						break
					}

					// 找到下一个即将开始的场次
					if (!nextSession && currentTime < sessionStart) {
						nextSession = session
					}
				}

				// 如果当前有正在进行的场次
				if (currentSession) {
					const [endHour, endMinute] = currentSession.endTime.split(':').map(Number)
					const endTime = endHour * 3600 + endMinute * 60
					const remainingSeconds = endTime - currentTime

					this.currentSessionText = currentSession.text
					this.formatTime(remainingSeconds)
				}
				// 如果没有正在进行的场次，但有即将开始的场次
				else if (nextSession) {
					const [startHour, startMinute] = nextSession.startTime.split(':').map(Number)
					const startTime = startHour * 3600 + startMinute * 60
					const remainingSeconds = startTime - currentTime

					this.currentSessionText = `距离${nextSession.text}开始还有`
					this.formatTime(remainingSeconds)
				}
				// 如果没有即将开始的场次，说明今天的活动都结束了，显示明天的第一场
				else {
					const tomorrowFirstSession = this.sessions[0]
					const [startHour, startMinute] = tomorrowFirstSession.startTime.split(':').map(Number)

					// 计算明天开始的秒数
					const tomorrowStartTime = (24 * 3600) + (startHour * 3600) + (startMinute * 60)
					const remainingSeconds = tomorrowStartTime - currentTime

					this.currentSessionText = `距离${tomorrowFirstSession.text}开始还有`
					this.formatTime(remainingSeconds)
				}
			},
			// 判断当前时间属于哪个场次
			getCurrentSession(sessions) {
				const now = new Date();
				const currentHour = now.getHours();
				const currentMinute = now.getMinutes();
				const currentTime = currentHour * 60 + currentMinute; // 转换为分钟数

				for (let i = 0; i < sessions.length; i++) {
					const session = sessions[i];
					const startParts = session.startTime.split(':').map(Number);
					const endParts = session.endTime.split(':').map(Number);

					// 将开始和结束时间转换为分钟数
					const startTime = startParts[0] * 60 + startParts[1];
					let endTime = endParts[0] * 60 + endParts[1];

					// 处理跨天的情况（例如 23:00-01:00）
					if (endTime <= startTime) {
						endTime += 24 * 60;
					}

					// 将当前时间也处理为跨天模式
					let currentTimeAdjusted = currentTime;
					if (currentTime < startTime && startTime > 12 * 60) {
						currentTimeAdjusted += 24 * 60;
					}

					// 判断当前时间是否在该场次区间内
					if (currentTimeAdjusted >= startTime && currentTimeAdjusted < endTime) {
						return session;
					}
				}

				// 如果没有找到匹配的场次，默认返回第一个场次（根据业务需求调整）
				return sessions[0] || null;
			},
			formatTime(seconds) {
				// 确保秒数不为负
				seconds = Math.max(0, seconds)

				const h = Math.floor(seconds / 3600)
				const m = Math.floor((seconds % 3600) / 60)
				const s = seconds % 60

				this.hours = h.toString().padStart(2, '0')
				this.minutes = m.toString().padStart(2, '0')
				this.seconds = s.toString().padStart(2, '0')
			},

			/**
			 * 请求静态数据只是为了代码不那么乱
			 * 分次请求未作整合
			 */
			async loadData() {
				// let carouselList = await this.$api.json('carouselList');
				// this.titleNViewBackground = carouselList[0].background;
				// this.swiperLength = carouselList.length;
				// this.carouselList = carouselList;
				try { // 广告
					const res = await getAd()
					if (res && res.data && typeof res.data === 'object' && 'code' in res.data && res.data.code ===
						200) {
						this.carouselList = res.data.data
						this.carouselList = this.carouselList.filter(item => item.position === 1 && item.enabled === 1);
						console.log(JSON.stringify(this.carouselList, null, 2));
						this.swiperLength = this.carouselList.length;
						// console.log(this.carouselList);
					} else {
						console.error('请求失败:', res?.data?.msg || '未知错误');
					}
				} catch (error) {
					console.error('接口异常:', error)
					this.$message.error('数据加载失败')
				}

				try { // 公告
					const res = await getArticle()
					if (res && res.data && typeof res.data === 'object' && 'code' in res.data && res.data.code ===
						200) {
						this.articleList = res.data.data
						// console.log(this.articleList);
					} else {
						console.error('请求失败:', res?.data?.msg || '未知错误');
					}
				} catch (error) {
					console.error('接口异常:', error)
					this.$message.error('数据加载失败')
				}

				try { // 分类商品
					const res = await getCategoryGoods()
					if (res && res.data && typeof res.data === 'object' && 'code' in res.data && res.data.code ===
						200) {
						this.categoryGoods = res.data.data
						// console.log("分类商品" + this.categoryGoods);
						// console.log(JSON.stringify(this.categoryGoods[0], null, 2));
					} else {
						console.error('请求失败:', res?.data?.msg || '未知错误');
					}
				} catch (error) {
					console.error('接口异常:', error)
					this.$message.error('数据加载失败')
				}

				try { // 一级目录
					const res = await getOrder()
					if (res && res.data && typeof res.data === 'object' && 'code' in res.data && res.data.code ===
						200) {
						this.categoryList = res.data.data
						// console.log(this.categoryList);
					} else {
						console.error('请求失败:', res?.data?.msg || '未知错误');
					}
				} catch (error) {
					console.error('接口异常:', error)
					this.$message.error('数据加载失败')
				}

				try {
					// 获取秒杀场次数据
					const qures = await getSeckillBatch();
					if (qures && qures.data && typeof qures.data === 'object' && 'code' in qures.data && qures.data
						.code === 200) {
						// 临时存储原始数据
						const seckillBatches = qures.data.data;

						// 处理场次数据：补全 startTime、endTime 和 text
						const sessions = seckillBatches.map((batch, index, array) => {
							const startTime = batch.seckillBatch;
							const hour = startTime.split(':')[0];
							const nextIndex = (index + 1) % array.length;

							return {
								startTime,
								endTime: array[nextIndex].seckillBatch,
								text: `${hour}点场`,
								// 保留原始字段（如果需要）
								seckillBatch: batch.seckillBatch,
							};
						});

						// 将处理后的数据赋值给 sessions
						this.sessions = sessions;
						
						console.log(JSON.stringify(this.sessions, null, 2));

						// 新增：获取当前应该使用的场次
						const currentSession = this.getCurrentSession(sessions);
						if (currentSession) {
							this.currentSeckillBatch = currentSession.seckillBatch;

							// 使用当前场次的 seckillBatch 请求商品列表
							const res = await getSeckillBathList({
								seckillBatch: this.currentSeckillBatch
							});
							if (res && res.data && typeof res.data === 'object' && 'code' in res.data && res.data
								.code === 200) {
								this.seckillBatchList = res.data.data;
							} else {
								console.error('请求商品列表失败:', res?.data?.msg || '未知错误');
							}
						} else {
							console.error('未找到当前有效的秒杀场次');
						}
					} else {
						console.error('请求场次数据失败:', qures?.data?.msg || '未知错误');
					}
				} catch (error) {
					console.error('接口异常:', error);
					this.$message.error('数据加载失败');
				}


				// 下载自带
				let goodsList = await this.$api.json('goodsList');
				this.goodsList = goodsList || [];


				try { // 新品首发
					const res = await getNewGoods()
					if (res && res.data && typeof res.data === 'object' && 'code' in res.data && res.data.code ===
						200) {
						this.newGoodsList = res.data.data
						// console.log(this.newGoodsList);
					} else {
						console.error('请求失败:', res?.data?.msg || '未知错误');
					}
				} catch (error) {
					console.error('接口异常:', error)
					this.$message.error('数据加载失败')
				}

				try { // 人气推荐
					const res = await getHotGoods()
					if (res && res.data && typeof res.data === 'object' && 'code' in res.data && res.data.code ===
						200) {
						this.hotGoodsList = res.data.data
						// console.log(this.hotGoodsList);
					} else {
						console.error('请求失败:', res?.data?.msg || '未知错误');
					}
				} catch (error) {
					console.error('接口异常:', error)
					this.$message.error('数据加载失败')
				}
			},
			//轮播图切换修改背景色
			swiperChange(e) {
				const index = e.detail.current;
				this.swiperCurrent = index;
				this.titleNViewBackground = this.carouselList[index].background;
			},
			//详情页
			navToDetailPage(item) {
				console.log(item);
				//测试数据没有写id，用title代替
				let id = item.id;
				uni.navigateTo({
					url: `/pages/product/product?id=${id}`
				})
			},
			navToDetailPage1(item) {
				console.log(JSON.stringify(item, null, 2));
				//测试数据没有写id，用title代替
				let id = item.dtsGoods.id;
				let seckillBatch = item.seckillBatch;
				let endTime = 0;
				for (var i = 0; i < this.sessions.length; i++) {
					if (this.sessions[i].startTime === item.seckillBatch) {
						endTime = this.sessions[i].endTime;
					}
				}
				
				uni.navigateTo({
					url: `/pages/product/product?goodsId=${id}&seckillBatch=${seckillBatch}&endTime=${endTime}`
				})
			},
			//分类跳转
			CategoryErJi(id) {
				uni.navigateTo({
					url: `/pages/product/list?fid=${id}&sid=0`
				})
			},
			//公告页
			navToArticlePage(item) {
				let id = item.id;
				console.log(id);
				uni.navigateTo({
					url: `/pages/index/article?id=${id}`
				});
			},
			// 搜索页
			navToSearchPage() {
				uni.navigateTo({
					url: `/pages/index/search`
				})
			},
			toNewGoodsDetail() {
				uni.navigateTo({
					url: `/pages/index/newGoodsDetail`
				})
			},
			toHotGoodsDetail() {
				uni.navigateTo({
					url: `/pages/index/hotGoodsDetail`
				})
			},
			navToSeckillDetailPage(item) {
				uni.navigateTo({
					url: `/pages/detail/seckillDetail`
				})
			},
		},
		// #ifndef MP
		// 标题栏input搜索框点击
		onNavigationBarSearchInputClicked: async function(e) {
			this.$api.msg('点击了搜索框');
		},
		//点击导航栏 buttons 时触发
		onNavigationBarButtonTap(e) {
			const index = e.index;
			if (index === 0) {
				this.$api.msg('点击了扫描');
			} else if (index === 1) {
				// #ifdef APP-PLUS
				const pages = getCurrentPages();
				const page = pages[pages.length - 1];
				const currentWebview = page.$getAppWebview();
				currentWebview.hideTitleNViewButtonRedDot({
					index
				});
				// #endif
				uni.navigateTo({
					url: '/pages/notice/notice'
				})
			}
		}
		// #endif

	}
</script>

<style lang="scss">
	/* #ifdef MP */
	.mp-search-box {
		position: absolute;
		left: 0;
		top: 30upx;
		z-index: 9999;
		width: 100%;
		padding: 0 80upx;

		.ser-input {
			flex: 1;
			height: 56upx;
			line-height: 56upx;
			text-align: center;
			font-size: 28upx;
			color: $font-color-base;
			border-radius: 20px;
			background: rgba(255, 255, 255, .6);
		}
	}

	page {
		.cate-section {
			position: relative;
			z-index: 5;
			border-radius: 16upx 16upx 0 0;
		}

		.carousel-section {
			padding: 0;

			.titleNview-placing {
				padding-top: 0;
				height: 0;
			}

			.carousel {
				.carousel-item {
					padding: 0;
				}
			}

			.swiper-dots {
				left: 45upx;
				bottom: 40upx;
			}
		}
	}

	/* #endif */


	page {
		background: #f5f5f5;
	}

	.m-t {
		margin-top: 16upx;
	}

	/* 头部 轮播图 */
	.carousel-section {
		position: relative;
		padding-top: 10px;

		.titleNview-placing {
			height: var(--status-bar-height);
			padding-top: 44px;
			box-sizing: content-box;
		}

		.titleNview-background {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 426upx;
			transition: .4s;
		}
	}

	.carousel {
		width: 100%;
		height: 350upx;

		.carousel-item {
			width: 100%;
			height: 100%;
			padding: 0 28upx;
			overflow: hidden;
		}

		image {
			width: 100%;
			height: 100%;
			border-radius: 10upx;
		}
	}

	.swiper-dots {
		display: flex;
		position: absolute;
		left: 60upx;
		bottom: 15upx;
		width: 72upx;
		height: 36upx;
		background-image: url();
		background-size: 100% 100%;

		.num {
			width: 36upx;
			height: 36upx;
			border-radius: 50px;
			font-size: 24upx;
			color: #fff;
			text-align: center;
			line-height: 36upx;
		}

		.sign {
			position: absolute;
			top: 0;
			left: 50%;
			line-height: 36upx;
			font-size: 12upx;
			color: #fff;
			transform: translateX(-50%);
		}
	}

	/* 分类 */
	.cate-section {
		display: flex;
		justify-content: space-around;
		align-items: center;
		flex-wrap: wrap;
		padding: 30upx 22upx;
		background: #fff;

		.cate-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 15px;
			font-size: $font-sm + 2upx;
			color: $font-color-dark;
		}

		/* 原图标颜色太深,不想改图了,所以加了透明度 */
		image {
			width: 88upx;
			height: 88upx;
			margin-bottom: 14upx;
			border-radius: 50%;
			opacity: .7;
			box-shadow: 4upx 4upx 20upx rgba(250, 67, 106, 0.3);
		}
	}

	.ad-1 {
		width: 100%;
		height: 210upx;
		padding: 10upx 0;
		background: #fff;

		image {
			width: 100%;
			height: 100%;
		}
	}

	/* 秒杀专区 */
	.seckill-section {
		padding: 4upx 30upx 24upx;
		background: #fff;

		.s-header {
			display: flex;
			align-items: center;
			height: 92upx;
			line-height: 1;

			.s-img {
				width: 140upx;
				height: 30upx;
			}

			.tip {
				font-size: $font-base;
				color: $font-color-light;
				margin: 0 20upx 0 40upx;
			}

			.timer {
				display: inline-block;
				width: 40upx;
				height: 36upx;
				text-align: center;
				line-height: 36upx;
				margin-right: 14upx;
				font-size: $font-sm+2upx;
				color: #fff;
				border-radius: 2px;
				background: rgba(0, 0, 0, .8);
			}

			.icon-you {
				font-size: $font-lg;
				color: $font-color-light;
				flex: 1;
				text-align: right;
			}
		}

		.floor-list {
			white-space: nowrap;
		}

		.scoll-wrapper {
			display: flex;
			align-items: flex-start;
		}

		.floor-item {
			width: 150upx;
			margin-right: 20upx;
			font-size: $font-sm+2upx;
			color: $font-color-dark;
			line-height: 1.8;

			image {
				width: 150upx;
				height: 150upx;
				border-radius: 6upx;
			}

			.price {
				color: $uni-color-primary;
			}
		}
	}

	.f-header {
		display: flex;
		align-items: center;
		height: 140upx;
		padding: 6upx 30upx 8upx;
		background: #fff;

		image {
			flex-shrink: 0;
			width: 80upx;
			height: 80upx;
			margin-right: 20upx;
		}

		.tit-box {
			flex: 1;
			display: flex;
			flex-direction: column;
		}

		.tit {
			font-size: $font-lg +2upx;
			color: #font-color-dark;
			line-height: 1.3;
		}

		.tit2 {
			font-size: $font-sm;
			color: $font-color-light;
		}

		.icon-you {
			font-size: $font-lg +2upx;
			color: $font-color-light;
		}
	}

	/* 团购楼层 */
	.group-section {
		background: #fff;

		.g-swiper {
			height: 650upx;
			padding-bottom: 30upx;
		}

		.g-swiper-item {
			width: 100%;
			padding: 0 30upx;
			display: flex;
		}

		image {
			width: 100%;
			height: 460upx;
			border-radius: 4px;
		}

		.g-item {
			display: flex;
			flex-direction: column;
			overflow: hidden;
		}

		.left {
			flex: 1.2;
			margin-right: 24upx;

			.t-box {
				padding-top: 20upx;
			}
		}

		.right {
			flex: 0.8;
			flex-direction: column-reverse;

			.t-box {
				padding-bottom: 20upx;
			}
		}

		.t-box {
			height: 160upx;
			font-size: $font-base+2upx;
			color: $font-color-dark;
			line-height: 1.6;
		}

		.price {
			color: $uni-color-primary;
		}

		.m-price {
			font-size: $font-sm+2upx;
			text-decoration: line-through;
			color: $font-color-light;
			margin-left: 8upx;
		}

		.pro-box {
			display: flex;
			align-items: center;
			margin-top: 10upx;
			font-size: $font-sm;
			color: $font-base;
			padding-right: 10upx;
		}

		.progress-box {
			flex: 1;
			border-radius: 10px;
			overflow: hidden;
			margin-right: 8upx;
		}
	}

	/* 分类推荐楼层 */
	.hot-floor {
		width: 100%;
		overflow: hidden;
		margin-bottom: 20upx;

		.floor-img-box {
			width: 100%;
			height: 320upx;
			position: relative;

			&:after {
				content: '';
				position: absolute;
				left: 0;
				top: 0;
				width: 100%;
				height: 100%;
				background: linear-gradient(rgba(255, 255, 255, .06) 30%, #f8f8f8);
			}
		}

		.floor-img {
			width: 100%;
			height: 100%;
		}

		.floor-list {
			white-space: nowrap;
			padding: 20upx;
			padding-right: 50upx;
			border-radius: 6upx;
			margin-top: -140upx;
			margin-left: 30upx;
			background: #fff;
			box-shadow: 1px 1px 5px rgba(0, 0, 0, .2);
			position: relative;
			z-index: 1;
		}

		.scoll-wrapper {
			display: flex;
			align-items: flex-start;
		}

		.floor-item {
			width: 180upx;
			margin-right: 20upx;
			font-size: $font-sm+2upx;
			color: $font-color-dark;
			line-height: 1.8;

			image {
				width: 180upx;
				height: 180upx;
				border-radius: 6upx;
			}

			.price {
				color: $uni-color-primary;
			}
		}

		.more {
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			flex-shrink: 0;
			width: 180upx;
			height: 180upx;
			border-radius: 6upx;
			background: #f3f3f3;
			font-size: $font-base;
			color: $font-color-light;

			text:first-child {
				margin-bottom: 4upx;
			}
		}
	}

	/* 猜你喜欢 */
	.guess-section {
		display: flex;
		flex-wrap: wrap;
		padding: 0 30upx;
		background: #fff;

		.guess-item {
			display: flex;
			flex-direction: column;
			width: 48%;
			padding-bottom: 40upx;

			&:nth-child(2n+1) {
				margin-right: 4%;
			}
		}

		.image-wrapper {
			width: 100%;
			height: 330upx;
			border-radius: 3px;
			overflow: hidden;

			image {
				width: 100%;
				height: 100%;
				opacity: 1;
			}
		}

		.title {
			font-size: $font-lg;
			color: $font-color-dark;
			line-height: 80upx;
		}

		.price {
			font-size: $font-lg;
			color: $uni-color-primary;
			line-height: 1;
		}
	}

	.announcement-section {
		height: 32px;
		padding: 10rpx;
		background-color: #fff;
		border-bottom: solid #999 1px;
		line-height: 20px;
	}

	.announcement-container {
		display: flex;
		align-items: center;
	}

	.announcement-title {
		font-weight: bold;
		margin-left: 20rpx;
		margin-right: 20rpx;
	}

	.announcement-swiper {
		font-size: 14px;
		color: #666666;
		flex: 1;
		height: 40rpx;
		/* 根据实际需求调整高度 */
	}

	.announcement-content {
		text-align: left;
	}
</style>